home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 3 of 3 / CHAPTE11 / GETID / PHONE.C < prev    next >
C/C++ Source or Header  |  1996-04-28  |  20KB  |  618 lines

  1. #include <windows.h> 
  2. #include <windowsx.h> 
  3. #include "phone.h" 
  4. #include "tapi.h"
  5.  
  6. #define BUFSIZE 256
  7. #define APIHIVERSION     0x00010028    /* 1.40 */
  8. #define APILOWVERSION    0x00010000    /* 1.0 */
  9. #define EXTHIVERSION     0x00010005    /* 1.5 */
  10. #define EXTLOWVERSION    0x00000009    /* 0.9 */ 
  11. #define MAX_PHONE        2
  12. #define OWNER            0
  13. #define MONITOR        1
  14.  
  15. LPCTSTR lpszAppName = "phoneGetID";
  16. LPCTSTR lpszTitle   = "phoneGetID"; 
  17.  
  18.  
  19. #if defined (WIN32)
  20.     #define IS_WIN32 TRUE
  21. #else
  22.     #define IS_WIN32 FALSE
  23. #endif
  24.  
  25. #define IS_NT      IS_WIN32 && (BOOL)(GetVersion() < 0x80000000)
  26. #define IS_WIN32S  IS_WIN32 && (BOOL)(!(IS_NT) && (LOBYTE(LOWORD(GetVersion()))<4))
  27. #define IS_WIN95   (BOOL)(!(IS_NT) && !(IS_WIN32S)) && IS_WIN32
  28.  
  29. HINSTANCE hInst;   // current instance
  30. HWND hWnd;         // parent window handle
  31. HWND hListWnd;     // listbox
  32. HDC  hdc;
  33. TEXTMETRIC  tm ;
  34.  
  35. BOOL RegisterWin95( CONST WNDCLASS* lpwc );
  36.  
  37.  
  38. int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
  39.                       LPTSTR lpCmdLine, int nCmdShow)
  40. {
  41.    MSG      msg;
  42.    WNDCLASS wc;
  43.  
  44.    wc.style         = CS_HREDRAW | CS_VREDRAW;
  45.    wc.lpfnWndProc   = (WNDPROC)WndProc;       
  46.    wc.cbClsExtra    = 0;                      
  47.    wc.cbWndExtra    = 0;                      
  48.    wc.hInstance     = hInstance;              
  49.    wc.hIcon         = LoadIcon (hInstance, lpszAppName); 
  50.    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
  51.    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
  52.    wc.lpszMenuName  = lpszAppName;              
  53.    wc.lpszClassName = lpszAppName;              
  54.  
  55.    if ( IS_WIN95 )
  56.    {
  57.       if ( !RegisterWin95( &wc ) )
  58.          return( FALSE );
  59.    }
  60.    else if ( !RegisterClass( &wc ) )
  61.       return( FALSE );
  62.  
  63.    hInst = hInstance; 
  64.  
  65.    hWnd = CreateWindow( lpszAppName, 
  66.                         lpszTitle,    
  67.                         WS_OVERLAPPEDWINDOW, 
  68.                         CW_USEDEFAULT, 0, 
  69.                         CW_USEDEFAULT, 0,  
  70.                         NULL,              
  71.                         NULL,              
  72.                         hInstance,         
  73.                         NULL               
  74.                       );
  75.  
  76.    if ( !hWnd ) 
  77.       return( FALSE );
  78.  
  79.    ShowWindow( hWnd, nCmdShow ); 
  80.    UpdateWindow( hWnd );         
  81.  
  82.    while( GetMessage( &msg, NULL, 0, 0) )   
  83.    {
  84.       TranslateMessage( &msg ); 
  85.       DispatchMessage( &msg );  
  86.    }
  87.  
  88.    return( msg.wParam ); 
  89. }
  90.  
  91.  
  92. BOOL RegisterWin95( CONST WNDCLASS* lpwc )
  93. {
  94.     WNDCLASSEX wcex;
  95.  
  96.    wcex.style         = lpwc->style;
  97.    wcex.lpfnWndProc   = lpwc->lpfnWndProc;
  98.    wcex.cbClsExtra    = lpwc->cbClsExtra;
  99.    wcex.cbWndExtra    = lpwc->cbWndExtra;
  100.    wcex.hInstance     = lpwc->hInstance;
  101.    wcex.hIcon         = lpwc->hIcon;
  102.    wcex.hCursor       = lpwc->hCursor;
  103.    wcex.hbrBackground = lpwc->hbrBackground;
  104.    wcex.lpszMenuName  = lpwc->lpszMenuName;
  105.    wcex.lpszClassName = lpwc->lpszClassName;
  106.  
  107.    // Added elements for Windows 95.
  108.    //...............................
  109.    wcex.cbSize = sizeof(WNDCLASSEX);
  110.    wcex.hIconSm = LoadImage(wcex.hInstance, lpwc->lpszClassName, 
  111.                             IMAGE_ICON, 16, 16,
  112.                             LR_DEFAULTCOLOR );
  113.             
  114.    return RegisterClassEx( &wcex );
  115. }
  116.  
  117. typedef struct tagMYINFO    // general application information
  118. {
  119.    HPHONEAPP phoneApp;      // instance handle TAPI gives back to us                                                                              through phoneInitialize()
  120.    DWORD dwNumDevices;     // number of available devices
  121.    DWORD dwAPIVersion;     // API version the phone supports
  122.     DWORD dwExtVersion;        // extended version
  123. } MYINFO;
  124.  
  125. typedef struct tagPHONEINFO  // information on an open phone
  126. {
  127.    HPHONE     hPhone;           // handle to the phone as returned by phoneOpen 
  128.     DWORD      dwDeviceID;            // device ID of the phone device
  129.     DWORD        dwRequestID;
  130.     char       szPhoneName[128]; // the phone's name 
  131. }PHONEINFO;
  132.  
  133. MYINFO myInfo;          //instance of MYINFO structure
  134. PHONEINFO myPhoneInfo[MAX_PHONE];  //instance of myPhoneInfo structure
  135.  
  136. LONG lRet;        //return code
  137. char buf[BUFSIZE];    // buffer for debug message
  138. char DataBuf[BUFSIZE]; //get/set data buffer;
  139.  
  140. DWORD i;
  141. DWORD dwHookSwitchDevs;
  142. DWORD dwLampMode;
  143. DWORD dwRingMode;
  144. DWORD dwRingVolume;
  145. DWORD dwHookSwitchVolume;
  146. DWORD dwPhoneStates;
  147. DWORD dwButtonModes;
  148. DWORD dwButtonStates;
  149. DWORD dwGain;
  150. HICON hIcon;
  151.  
  152. LONG lRet;
  153. char buf[BUFSIZE];
  154.  
  155. PHONECAPS*             pPhoneCaps;
  156. PHONEBUTTONINFO*  pButtonInfo;
  157. VARSTRING*            pVarString;
  158. PHONESTATUS*        pPhoneStatus;
  159. PHONEEXTENSIONID    ext_id;                                             
  160.  
  161.  
  162. LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
  163. {
  164.    switch( uMsg )
  165.    {
  166.       case WM_COMMAND :
  167.          switch( LOWORD( wParam ) )
  168.          {
  169.             case IDM_RUN :
  170.                pVarString = (VARSTRING *) calloc (1, sizeof(VARSTRING)+1000);
  171.                    pVarString->dwTotalSize = sizeof(VARSTRING) + 1000;
  172.                    lRet = phoneGetID(myPhoneInfo[OWNER].hPhone, pVarString, "tapi/phone");
  173.                    if (lRet == 0)
  174.                   {
  175.                    wsprintf(buf, "phoneGetID succeeded!");
  176.                        SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  177.                      strcpy(buf, ((LPSTR)(pVarString)+pVarString->dwStringOffset));
  178.                      strcat( buf, " is the ID for current phone device." );
  179.                      SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  180.                  }
  181.                      else 
  182.                   {
  183.                        wsprintf( buf,"phoneGetID failed, err=x%lx", lRet);
  184.                       phoneError(lRet);
  185.                   }    
  186.                 
  187.                     free (pVarString);
  188.                break;
  189.  
  190.             case IDM_EXIT :
  191.                for (i = 0; i < myInfo.dwNumDevices; i++)
  192.                     phoneClose(myPhoneInfo[i].hPhone);
  193.                 
  194.                    phoneShutdown(myInfo.phoneApp);
  195.                DestroyWindow( hWnd );
  196.                break;
  197.          
  198.             case IDM_ABOUT :
  199.                 DialogBox( hInst, "AboutBox", hWnd, (DLGPROC)About );
  200.                break;
  201.          }
  202.                 
  203.             return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
  204.  
  205.       
  206.        case WM_CREATE :
  207.  
  208.           hdc = GetDC (hWnd) ;
  209.           GetTextMetrics (hdc, &tm) ;
  210.           ReleaseDC (hWnd, hdc) ;
  211.  
  212.           hListWnd = CreateWindowEx( 0, "listbox", 
  213.                         " ",    
  214.                         WS_CHILD | WS_VISIBLE,  
  215.                         tm.tmAveCharWidth, tm.tmHeight * 3, 
  216.                         tm.tmAveCharWidth * 16 +
  217.                                    GetSystemMetrics (SM_CXVSCROLL), 
  218.                         tm.tmHeight * 5,  
  219.                         hWnd,              
  220.                         NULL,              
  221.                         hInst,         
  222.                         NULL               
  223.                         );
  224.       
  225.              //phoneInitialize
  226.                //...............................................
  227.             lRet = phoneInitialize(&myInfo.phoneApp, hInst, phoneCallback, lpszAppName, &myInfo.dwNumDevices);
  228.             if (lRet == 0) 
  229.             {
  230.                 
  231.                wsprintf(buf, "phoneInitialize succeeded!");
  232.                    SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  233.             }
  234.                
  235.                else 
  236.                {
  237.                    wsprintf( buf,"phoneInitialize failed, err=x%lx",lRet);
  238.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  239.                     phoneError(lRet);
  240.                     break;
  241.             }                    
  242.                
  243.             //phoneNegotiateAPIVersion
  244.                   //...............................................
  245.             lRet = phoneNegotiateAPIVersion(myInfo.phoneApp, 0, APILOWVERSION, APIHIVERSION, 
  246.                                                     &myInfo.dwAPIVersion, &ext_id);
  247.             if (lRet == 0)                        
  248.             {
  249.                wsprintf(buf, "phoneNegotiateAPIVersion succeeded!");
  250.                       SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  251.             }
  252.                   else 
  253.                   {
  254.                    wsprintf(buf, "phoneNegotiateAPIVersion failed, err=x%lx", lRet);
  255.                     SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  256.                     phoneError(lRet);
  257.                     phoneShutdown(myInfo.phoneApp);
  258.                break;
  259.              }
  260.  
  261.                //phoneNegotiateExtVersion
  262.                //...............................................
  263.             lRet = phoneNegotiateExtVersion(myInfo.phoneApp, 0, myInfo.dwAPIVersion, EXTLOWVERSION, 
  264.                                                 EXTHIVERSION, &myInfo.dwExtVersion);
  265.             if (lRet == 0)                        
  266.             {
  267.                     wsprintf(buf, "phoneNegotiateExtVersion succeeded!");
  268.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  269.               }
  270.                   else 
  271.                {
  272.                     wsprintf(buf, "phoneNegotiateExtVersion failed, err=x%lx", lRet);
  273.                       SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  274.                       phoneError(lRet);
  275.                }
  276.  
  277.             //phoneOpen
  278.                //................................................................
  279.                for (i = 0; i < myInfo.dwNumDevices; i++)
  280.                {
  281.                    if ( i == 0)
  282.                        lRet = phoneOpen(myInfo.phoneApp,i,&myPhoneInfo[i].hPhone,
  283.                                  myInfo.dwAPIVersion,0,(DWORD)phoneCallback, PHONEPRIVILEGE_OWNER);
  284.                    else
  285.                        lRet = phoneOpen(myInfo.phoneApp,i,&myPhoneInfo[i].hPhone,
  286.                                  myInfo.dwAPIVersion,0,(DWORD)phoneCallback, PHONEPRIVILEGE_MONITOR);
  287.                    
  288.                    if (lRet == 0)
  289.                    {
  290.                      wsprintf(buf, "phoneOpen succeeded!");
  291.                         SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  292.                   pPhoneCaps = (PHONECAPS *) calloc (1, sizeof(PHONECAPS)+1000);
  293.                       pPhoneCaps->dwTotalSize = sizeof(PHONECAPS) + 1000;
  294.                          
  295.                       phoneGetDevCaps(myInfo.phoneApp,i,
  296.                       myInfo.dwAPIVersion, myInfo.dwExtVersion, pPhoneCaps);
  297.                       strcpy(buf, ((LPSTR)(pPhoneCaps)+pPhoneCaps->dwProviderInfoOffset));
  298.                   strcat( buf, " is the phone providor's name." );
  299.                   SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  300.                   strcpy(buf, ((LPSTR)(pPhoneCaps)+pPhoneCaps->dwPhoneNameOffset));
  301.                      
  302.                   if (i == 0)
  303.                   {
  304.                      strcat( buf, " is the phone's name opened with OWNER privilege." );
  305.                      SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  306.                   }
  307.                   else
  308.                   {
  309.                      strcat( buf, " is the phone's name opened with MONITOR privilege." );
  310.                      SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  311.                   }
  312.                }
  313.                    else 
  314.                    {
  315.                        wsprintf( buf,"phoneOpen failed, err=x%lx", lRet);
  316.                        phoneError(lRet);
  317.                       break;
  318.                }
  319.                   } 
  320.  
  321.             break;
  322.       
  323.       case WM_SIZE:
  324.           MoveWindow(hListWnd, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
  325.          break;
  326.  
  327.       case WM_DESTROY :
  328.          PostQuitMessage(0);
  329.          break;
  330.             
  331.       default :
  332.             return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
  333.    }
  334.  
  335.    return( 0L );
  336. }
  337.  
  338.  
  339.  
  340.  
  341. /****************************************************************************
  342.     FUNCTION: phoneCallback
  343.     PURPOSE:  callback function handles phone events
  344. ****************************************************************************/
  345. LRESULT CALLBACK phoneCallback (DWORD  dwDevice, DWORD dwMsg,
  346.                                 DWORD dwCallbackInst, DWORD dwParam1,
  347.                                 DWORD dwParam2,DWORD dwParam3)
  348. {
  349.     
  350.     switch (dwMsg)
  351.     {
  352.         case PHONE_REPLY:
  353.             if (dwParam1 == myPhoneInfo[OWNER].dwRequestID) 
  354.                    if (dwParam2 != 0)
  355.                 {
  356.                        wsprintf( buf,"Function failed, err=x%lx", lRet);
  357.                        phoneError(lRet);
  358.                     SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  359.                    }
  360.             break;       
  361.  
  362.         case PHONE_STATE:
  363.         
  364.             if (dwParam1 == PHONESTATE_RINGMODE)
  365.             {
  366.                 lRet = phoneGetRing(myPhoneInfo[OWNER].hPhone, &dwRingMode, &dwRingVolume);
  367.                 if (lRet == 0)
  368.                {
  369.                 wsprintf(buf, "phoneGetRing succeeded!");
  370.                    SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  371.                if (dwRingMode == 0)
  372.                     {
  373.                         wsprintf(buf, "The phone device is currently not ringing.");
  374.                         SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  375.                }
  376.                     else
  377.                     {
  378.                         wsprintf(buf, "The phone is ringing with a Ring Mode pattern of x%lx", dwRingMode);
  379.                         SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  380.                    wsprintf(buf, "The phnes's Ring Volume is x%lx", dwRingVolume);
  381.                         SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  382.                     }
  383.                }
  384.                  else 
  385.                {
  386.                     wsprintf( buf,"phoneGetRing failed, err=x%lx", lRet);
  387.                    phoneError(lRet);
  388.                }        
  389.               
  390.               break;
  391.               }
  392.             
  393.  
  394.             if (dwParam1 == PHONESTATE_SPEAKERHOOKSWITCH)
  395.             {   
  396.                 lRet = phoneGetHookSwitch(myPhoneInfo[OWNER].hPhone, &dwHookSwitchDevs);
  397.                 if (lRet == 0)
  398.                {
  399.                wsprintf(buf, "phoneGetHookSwitch succeeded!");
  400.                       SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  401.                
  402.                if (dwHookSwitchDevs & PHONEHOOKSWITCHDEV_SPEAKER)
  403.                     {
  404.                         wsprintf(buf, "The phone's HookSwitch Speaker is offhook!");
  405.                        SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  406.                     }
  407.                     else
  408.                     {
  409.                    wsprintf(buf, "The phone's HookSwitch Speaker is onhook!");
  410.                         SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  411.                     }
  412.  
  413.               }
  414.                  else 
  415.                {
  416.                       wsprintf( buf,"phoneGetHookSwitch failed, err=x%lx", lRet);
  417.                    phoneError(lRet);
  418.                }    
  419.             break;                
  420.             }
  421.  
  422.             if (dwParam1 == PHONESTATE_SPEAKERVOLUME)
  423.             {   
  424.                 lRet = phoneGetVolume(myPhoneInfo[OWNER].hPhone, PHONEHOOKSWITCHDEV_SPEAKER, &dwHookSwitchVolume);
  425.                if (lRet == 0)
  426.                {
  427.                 wsprintf(buf, "phoneGetVolume succeeded!");
  428.                    SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  429.                wsprintf(buf, "The current volume for the Speaker Hookswitch is x%lx", dwHookSwitchVolume);
  430.                     SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  431.                }
  432.                  else 
  433.                {
  434.                     wsprintf( buf,"phoneGetVolume failed, err=x%lx", lRet);
  435.                    phoneError(lRet);
  436.                }    
  437.             break;                
  438.             }
  439.  
  440.             if (dwParam1 == PHONESTATE_SPEAKERGAIN)
  441.             {   
  442.                 lRet = phoneGetGain(myPhoneInfo[OWNER].hPhone, PHONEHOOKSWITCHDEV_SPEAKER, &dwGain);
  443.                 if (lRet == 0)
  444.                {
  445.                   wsprintf(buf, "phoneGetGain succeeded!");
  446.                       SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  447.                     wsprintf(buf, "The current Gain is x%lx", dwGain);
  448.                     SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  449.                }
  450.                  else 
  451.                {
  452.                       wsprintf( buf,"phoneGetGain failed, err=x%lx", lRet);
  453.                     phoneError(lRet);
  454.                }
  455.             break;                
  456.             }
  457.             
  458.             if (dwParam1 == PHONESTATE_DISPLAY)
  459.             {   
  460.                 pVarString = (VARSTRING *) calloc (1, sizeof(VARSTRING)+1000);
  461.                 pVarString->dwTotalSize = sizeof(VARSTRING) + 1000;
  462.                 lRet = phoneGetDisplay(myPhoneInfo[OWNER].hPhone, pVarString);
  463.                 if (lRet == 0)
  464.                {
  465.                   wsprintf(buf, "phoneGetDisplay succeeded!");
  466.                       SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  467.                strcpy(buf, lpszTitle);
  468.                //strcpy(buf, ((LPSTR)(pVarString)+pVarString->dwStringOffset));
  469.                strcat( buf, " is the current phone display." );
  470.                SendMessage(hListWnd, LB_INSERTSTRING, (WPARAM) -1, (LONG) (LPSTR) buf) ;
  471.                }
  472.                  else 
  473.                {
  474.                    wsprintf( buf,"phoneGetDisplay failed, err=x%lx", lRet);
  475.                   phoneError(lRet);
  476.                }    
  477.                     
  478.                 free (pVarString);
  479.                 break;
  480.               }
  481.    }
  482.    return (TRUE);
  483.  
  484.  
  485. /****************************************************************************
  486.     FUNCTION: phoneError
  487.     PURPOSE:  phone error messages
  488. ****************************************************************************/
  489. void phoneError (LONG lrc)
  490. {
  491.  switch (lrc) {
  492.     case PHONEERR_INVALAPPHANDLE:
  493.        MessageBox (hWnd, "Invalid app handle.", "", MB_OK);
  494.        break;
  495.     case PHONEERR_BADDEVICEID:
  496.        MessageBox (hWnd,"The specified phone device ID is out of range.", "", 
  497.                    MB_OK);
  498.        break;
  499.     case PHONEERR_INCOMPATIBLEAPIVERSION:
  500.        MessageBox (hWnd, "Incompatible API version.", "", MB_OK);
  501.        break;
  502.     
  503.     case PHONEERR_INVALBUTTONLAMPID:
  504.        MessageBox (hWnd, "Invalid Button Lamp ID.", "", MB_OK);
  505.        break;
  506.  
  507.     case PHONEERR_INVALBUTTONMODE:
  508.        MessageBox (hWnd, "Invalid Button Mode.", "", MB_OK);
  509.        break;
  510.  
  511.     case PHONEERR_INVALBUTTONSTATE:
  512.        MessageBox (hWnd, "Invalid Button State", "", MB_OK);
  513.        break;
  514.  
  515.     case PHONEERR_INUSE:
  516.        MessageBox (hWnd, "Phone in Use.", "", MB_OK);
  517.        break;
  518.     
  519.     case PHONEERR_INVALHOOKSWITCHDEV:
  520.        MessageBox (hWnd, "Invalid Hookswitch Device.", "", MB_OK);
  521.        break;
  522.  
  523.     case PHONEERR_INVALHOOKSWITCHMODE:
  524.        MessageBox (hWnd, "Invalid Hookswitch Device Mode.", "", MB_OK);
  525.        break;
  526.  
  527.     case PHONEERR_INVALLAMPMODE:
  528.        MessageBox (hWnd, "Invalid Lamp Mode.", "", MB_OK);
  529.        break;
  530.      
  531.     case PHONEERR_INCOMPATIBLEEXTVERSION:
  532.        MessageBox (hWnd, "Incompatible extension version.","", MB_OK);
  533.        break;
  534.     case PHONEERR_NOMEM:
  535.        MessageBox (hWnd, "No memory","", MB_OK);
  536.        break;
  537.     case PHONEERR_NODRIVER:
  538.        MessageBox (hWnd, "No driver loaded", "", MB_OK);
  539.        break;
  540.     case PHONEERR_RESOURCEUNAVAIL:
  541.        MessageBox (hWnd, "Resource overcommittment", "", MB_OK);
  542.        break;
  543.     case PHONEERR_ALLOCATED:
  544.        MessageBox (hWnd, "Allocation error", "", MB_OK);
  545.        break;
  546.     case PHONEERR_INVALDATAID:
  547.        MessageBox (hWnd, "The data ID is out of range.", "", MB_OK);
  548.        break;
  549.     case PHONEERR_INVALDEVICECLASS:
  550.        MessageBox (hWnd, "The device class was invalid.", "", MB_OK);
  551.        break;
  552.     case PHONEERR_INVALPOINTER:
  553.        MessageBox (hWnd, "The specified pointer parameter is invalid.",
  554.                    "", MB_OK);
  555.        break;
  556.     case PHONEERR_OPERATIONFAILED:
  557.        MessageBox (hWnd, "Operation failed.", "", MB_OK);
  558.        break;
  559.     case PHONEERR_INVALPHONEHANDLE:
  560.        MessageBox (hWnd, "Invalid phone handle", "", MB_OK);
  561.        break;
  562.     case PHONEERR_INVALPHONESTATE :
  563.        MessageBox (hWnd, "Invalid call state for this function.", "", MB_OK);
  564.        break;
  565.     case PHONEERR_INVALPRIVILEGE:
  566.        MessageBox (hWnd, "Invalid privilege for this function.", "", MB_OK);
  567.        break;
  568.     case PHONEERR_NODEVICE:
  569.        MessageBox (hWnd, "No associated device for given class",
  570.                    "", MB_OK);
  571.        break;
  572.     case PHONEERR_OPERATIONUNAVAIL:
  573.        MessageBox (hWnd, "The operation is unavailable",
  574.                    "", MB_OK);
  575.        break;
  576.     case PHONEERR_INVALPARAM:
  577.         MessageBox(hWnd, "Invalid Paramater", "", MB_OK);
  578.        break; 
  579.  
  580.     case PHONEERR_INVALRINGMODE:
  581.             MessageBox(hWnd, "Invalid Ring Mode", "", MB_OK);
  582.        break; 
  583.  
  584.     }
  585.     
  586.              
  587. }
  588.  
  589. LRESULT CALLBACK About( HWND hDlg,           
  590.                         UINT message,        
  591.                         WPARAM wParam,       
  592.                         LPARAM lParam)
  593. {
  594.    switch (message) 
  595.    {
  596.        case WM_INITDIALOG: 
  597.                return (TRUE);
  598.  
  599.        case WM_COMMAND:                              
  600.                if (   LOWORD(wParam) == IDOK         
  601.                    || LOWORD(wParam) == IDCANCEL)    
  602.                {
  603.                        EndDialog(hDlg, TRUE);        
  604.                        return (TRUE);
  605.                }
  606.                break;
  607.    }
  608.  
  609.    return (FALSE); 
  610. }
  611.  
  612.  
  613.  
  614.  
  615.  
  616.  
  617.